The present invention relates to methods and apparatus for processing images. More particularly, but not exclusively, the invention relates to a method for generating a model from a set of images, the model being useable to determine whether an input image is a member of the set of images. Some of the methods described herein also allow an area of input image best satisfying a model to be identified.
The use of computers in the field of image recognition is well known. One particular application of image recognition is in the field of industrial inspection. Here, a computer is provided with an image and it is required that output data indicating whether or not the input image is a member of a class of images is generated. The class of images may represent permissible variation of a particular component which is operated on by an industrial process.
It is known to carry out the processing described above using a model representing the class of images. Such models are typically created by receiving and processing a plurality of training images, the plurality of training images being examples of the class of images of interest. That is, given that many industrial processes have permissible ranges of variation, the plurality of training images will be examples which span the permissible range of variation, such that the generated model properly represents the permissible range of variation.
While the use of models of the type described above has enjoyed considerable success, it is not without its disadvantages. One disadvantage is that it is often difficult to generate a sufficiently accurate model, for example because a small number of the plurality of training images may erroneously not properly represent images which are within the permissible range of variation. The inclusion of such images in the model building process can result in models which wrongly indicate that input images are within the permissible range of variation when, in fact, this is not the case.
Another disadvantage of the use of models of the type set out above is that typically when an input image is provided which the model determines is not within the permissible range of variation, an operator is provided with no information of why this might be the case, simply an indication that the input image is not in accordance with the model.
Additionally, some existing techniques are such that when it is desired to identify an area of an input image which best satisfies a model, the techniques fail to even identify the area best satisfying the model, if that area insufficiently satisfies the model. That is, where no area of an input image sufficiently satisfies a model, it is often useful to provide information identifying the area which nevertheless best satisfies the model. Existing techniques often fail to do this.
It is an object of embodiments of the present invention to obviate or mitigate one or more of the problems set out above.
According to a first aspect of the present invention, there is provided a method of generating a model from a set of images. The method comprises processing a plurality of data items, each data item representing an image of said set of images, to determine variability between said plurality of data items. The model is generated based upon said data items and said variability wherein the influence of each of said data items upon the generated model is determined by a relationship between a respective one of said data items and said variability.
The invention therefore allows a model to be created in which the influence of a particular data item upon the created model is determined by relationship between the particular data item and the variability between the plurality of data items. Thus, a data item which is far outside the normal range of variability has a relatively low influence on the generated model. The created model is therefore considered to be a robust model, in that it is not affected to too great an extent by data items lying outside the normal range of variability used in its creation.
Each of the plurality of data items may be a normalized data item. Normalization of a data item can be carried out in any convenient way.
A plurality of initial data items may be received, each initial data item comprising a plurality of elements. A median value for each element may be computed based upon values of that element in each of said plurality of initial data items. The use of a median value in this way has been found to allow for robust normalization. More particularly, the use of a median value has advantages over the use of a mean value given that a median value is not unduly affected by a small number of outlying values.
A median absolute deviation (MAD) value for each element may be computed based upon values of that element in each of said plurality of initial data items. Again, the use of the MAD is advantageous given that it is relatively robust to outlying element values.
The method may further comprise processing each element of a respective data item with reference to a respective median value and MAD value to determine a normalization factor for the respective data item. A respective normalized data item for each initial data item can then be generated by applying said normalization factor to the respective initial data item. This method of normalization is advantageous given that its use of median and MAD values means that it is relatively robust to the effect of outlying data element values.
Generating the model based upon said data items may comprise associating a weight with each of said data items. The weights may be based upon said variability. The weights can be arranged such that influence of outlying data items is minimised. A weight for each of said data items may be computed.
Computing a weight for a respective data item may comprise determining a relationship between the respective data item and an average data item. The average data item may be a median data item. The use of a median data item is preferred as this results in the weights being computed in such a way that the effect of outlying data items is minimised.
The method may comprise determining a value indicating a confidence in each of said data items. The confidence of a respective data item may be based upon the relationship between the respective data item and the average data item and variability of said data items.
The method may further comprise generating a probability distribution from said values indicating a confidence in each of said data items, and determining a probability value for each of said data items based upon the generated distribution. The weight associated with a particular data item may be a function of the determined probability value. The function may provide a first weight value when said probability is within a first range, and the function may provide a weight value in a second range when said value indicating probability is in a third range.
Generating the model may comprise determining a difference relationship between each of said data items and an average data item to generate a plurality of difference data items. The average data item may be a weighted mean of said data items, the weighted mean being based upon the determined weights. The use of such a weighted mean is beneficial in providing the method with additional robustness.
The determined weights may be applied to said difference data items and a matrix indicating how each weighted difference data item varies with reference to each other weighted difference data item may be generated. The matrix may be a covariance matrix.
Generating the model may further comprise establishing the eigensystem of the said matrix to generate a plurality of eigenvectors and eigenvalues and creating a matrix containing at least some of said plurality of eigenvectors. In this way, principal component analysis is performed.
Generating said plurality of eigenvectors and eigenvalues may further comprise processing a further matrix, said further matrix being of smaller size than said matrix. More particularly, the eigenvalues may be derived from said further matrix.
The model may be a statistical model. For example, the model may have a form:m+Pbwhere m is an average data item;                P is a matrix indicating permissible variation; and        b is an example instance of the model.        
Each data item may be a vector, and each element of each data item may represent a pixel value.
According to a second aspect of the invention, there is provided, a method of generating data indicating how well an input image satisfies a model representing a set of images. The method comprises processing an input data item representing the input image to generate data indicating how well the image can be represented by the model. The input data item comprises a plurality of elements, each element representing a respective image element of the input image. Processing the input data item to determine how well the input image satisfies the model comprises determining an influence which each element of the input data item should have upon the generated data, and generating said data such that each element of the input data item has the determined influence.
The use of an influence in this way ensures that elements of the input data item which are anomalous have a relatively low influence upon the determination, thereby ensuring the robustness of the determination when some element values (e.g. pixel values) are anomalous.
Determining an influence which an element of the input data item should have upon the generated data may comprise generating a weight data item for each element of the input data item.
Generating said data such that each element has the determined influence may comprise determining a relationship between each element in a plurality of sample data items representing images of the set of images and a respective element of the input data item. A respective one of said weight data items may be applied to each relationship to generate said data indicating how well the input image satisfies the model.
Generating each weight data item may comprise determining a relationship between an element of the input data item and the variability of an element of a plurality of sample data items. The relationship between an element of the input data item and the variability of an element of a plurality of sample data items may be a relationship between the difference between the element of the input data item and an average element value, and said variability.
Each of said weight data items may be generated using iterative processing.
The method may further comprise generating output data indicating the influence of at least some of said input elements upon said determination. The output data may comprise graphical output data indicating pixels of the input image which contribute relatively little to the determination. In this way, diagnostic feedback can be provided to a user, for example using an appropriate graphical user interface.
The data indicating how well an input image satisfies a model may be generated iteratively.
The input data item may be a normalized input data item.
According to a third aspect of the present invention, there is provided, a method of identifying an area of an image which best satisfies a model. The method comprises processing a first area of said image with reference to the model, said processing generating displacement information. A second area of said image is processed with reference to the model, the second area being selected based upon said displacement information.
In this way, the third aspect of the invention generates data which can be used to focus and direct a search intended to locate an area of an image which best satisfies the model. This can be beneficial in improving the efficiency with which the area of an image best satisfying a model is located.
The displacement information may comprise translational displacement information and/or rotational displacement information.
Processing the first and/or second area of the image with reference to the model may comprise carrying out processing as described above in connection with the second aspect of the invention.
According to a fourth aspect of the present invention, there is provided, a method of generating model data representing a model of a class of images. The method comprises processing a plurality of sample data items to generate said model data, each sample data item comprising displacement information.
In this way, the fourth aspect of the invention generates a model which includes displacement information which can be useful when the model is applied to an input image.
The method may further comprise receiving an input data item and generating sample data items based upon a plurality of displaced versions of said input data item.
The processing may comprise performing principal component analysis.
It will be appreciated that the invention can be implemented in any convenient way. For example, aspects of the invention provide not only methods but also suitably configured apparatus. The invention may be carried out by means of suitable computer programs which may be carried out on appropriate carrier media. Such media includes both tangible carrier media and intangible carrier media. When the methods described above are implemented using a computer the various images and models may be represented by way of digital data which is stored in a suitable memory in the computer.